import { defineStore } from 'pinia';

export const useCommentStore = defineStore('comment', {
  state: () => {
    return {
      comments: [
        {
          uid: '罗师傅',
          content: '很不错！很不错！很不错！很不错！很不错！很不错！很不错！很不错！很不错！',
          rate: 0,
          createdAt: '2023-02-27',
        },
        {
          uid: '罗师傅',
          content: '很不错！很不错！很不错！很不错！很不错！很不错！很不错！很不错！很不错！',
          rate: 0,
          createdAt: '2023-02-27',
        },
        {
          uid: '罗师傅',
          content: '很不错！很不错！很不错！很不错！很不错！很不错！很不错！很不错！很不错！',
          rate: 0,
          createdAt: '2023-02-27',
        },
      ]
    };
  },
  // 也可以这样定义
  // state: () => ({ count: 0 })
  actions: {
    getComment() {
      uni.request({
        url: '/comment',
        success: ({ data }) => {
          this.$patch(data)
        }
      })
    },
  },
});